package book;

/**
 * Created with IntelliJ IDEA.
 * Description:定义书架类
 * User: 86183
 */
public class BookList {
    private Book[] books = new Book[10];//定义一个数组类型的字段
    private int useSize;//表示在books占几个元素(有几本书)
    //构造方法,初始化books数组
    public BookList() {
        //创建了一个 Book对象并实例化，该对象的引用被存储在数组元素中
        this.books[0] = new Book("西游记","吴承恩",70,"小说");
        this.books[1] = new Book("红楼梦","曹雪芹",50,"小说");
        this.books[2] = new Book("三国演义","罗贯中",60,"小说");
        this.books[3] = new Book("水浒传","施耐庵",60,"小说");
        useSize = 4;
    }

    public Book getBooks(int cur) {
        //根据索引cur从 books数组（书架）中返回对应的Book对象
        return books[cur];
    }

    public Book[] getBooks() {
        return books;
    }

    public void setBooks(int cur ,Book book) {
        this.books[cur] = book;
    }

    public int getUseSize() {
        return useSize;
    }

    public void setUseSize(int useSize) {
        this.useSize = useSize;
    }
}
